import pymysql
'''
通过用户名或者年龄获取用户信息
'''
# 创建连接对象
conn = pymysql.connect(user='root', password='root', database='advanced', charset='utf8')
cursor = conn.cursor()

# 执行sql语句
name = input('姓名：')
age = int(input('年龄：'))
# name = ' or 1=1 or '
sql = "select * from student where stu_name = %s or stu_age = %s"
print(sql)
rows = cursor.execute(sql, [name,age])
if rows:
    # 获取结果集
    students = cursor.fetchall()
    print(students)
else:
    print('没有要找的学生')
# 关闭资源
cursor.close()
conn.close()































